package com.biz.primus.base.vo.commodity;


import com.biz.primus.common.enums.EnumerableValue;
import com.biz.primus.common.enums.converter.BaseEnumValueConverter;

/**
 * 商品上下架状态
 *
 * @author david-liu
 * @date 2016年12月15日
 * @reviewer
 * @see
 */
public enum SaleStatus implements EnumerableValue {
    ON_SALE(10, "已上架"), OFF_SALE(0, "未上架");

    public static class Converter extends BaseEnumValueConverter<SaleStatus> {
    }

    SaleStatus(Integer value, String description) {
        this.value = value;
        this.description = description;
    }

    private Integer value;

    private String description;

    @Override
    public int getValue() {
        return value;
    }

    public String getDescription() {
        return description;
    }

    public static SaleStatus valueOf(Integer value){
//        todo:大量数据无上下架状态,测试默认上架
        if (value == null){
            return ON_SALE;
        }
        switch (value){
            case 0:
                return OFF_SALE;
            case 10:
                return ON_SALE;
            default:
                return OFF_SALE;
        }
    }



}
